//
//  UILabel+StringFrame.m
//  SD
//
//  Created by 伟大大 on 2018/3/10.
//  Copyright © 2018年 丁伟佳. All rights reserved.
//

#import "UILabel+StringFrame.h"

@implementation UILabel (StringFrame)

- (CGSize)boundingRectWithSize:(CGSize)size
{
    // 设置段落
//    NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
////    paragraphStyle.minimumLineHeight = 2;
//    paragraphStyle.lineSpacing = -10;
//    // NSKernAttributeName字体间距
//    //    NSDictionary *attributes = @{ NSParagraphStyleAttributeName:paragraphStyle,NSKernAttributeName:@1.0f};
//    //    NSMutableAttributedString * attriStr = [[NSMutableAttributedString alloc] initWithString:self attributes:attributes];
//
//    NSDictionary *attribute = @{NSParagraphStyleAttributeName:paragraphStyle,NSKernAttributeName:@1.0f,NSFontAttributeName: self.font};
//
//    CGSize retSize = [self.text boundingRectWithSize:size
//                                             options:\
//                      NSStringDrawingTruncatesLastVisibleLine |
//                      NSStringDrawingUsesLineFragmentOrigin |
//                      NSStringDrawingUsesFontLeading
//                                          attributes:attribute
//                                             context:nil].size;
    
    NSDictionary *attribute = @{NSFontAttributeName: self.font};

    CGSize retSize = [self.text boundingRectWithSize:size
                                             options:\
                      NSStringDrawingTruncatesLastVisibleLine |
                      NSStringDrawingUsesLineFragmentOrigin |
                      NSStringDrawingUsesFontLeading
                                          attributes:attribute
                                             context:nil].size;

    return retSize;
    
//    NSDictionary *attribute = @{NSFontAttributeName: self.font};
//
//    CGSize retSize = [self.text boundingRectWithSize:size
//                                             options:\
//                      NSStringDrawingTruncatesLastVisibleLine |
//                      NSStringDrawingUsesLineFragmentOrigin |
//                      NSStringDrawingUsesFontLeading
//                                          attributes:attribute
//                                             context:nil].size;
//
//    return retSize;
}
@end
